package model

import (
	"fmt"
)

type Student struct {
	Name string
	Grade string
	Id string
	Gender string
	books []*Book
}

func CreateStudent(name, grade, id, gender string) *Student {
	stu := &Student{
		Name: name,
		Grade: grade,
		Id: id,
		Gender: gender,
	}
	return stu
}

func (s *Student) BorrowBook (b *Book) {
	s.books = append(s.books, b)
}

func (s *Student) BackBook (b *Book) {
	for i := 0; i < len(s.books); i++ {
		if s.books[i].Name == b.Name {
			s.books = append(s.books[:i], s.books[i+1:]...)
			return
		}
	}
	fmt.Println("并没有这本书")
}

func (s *Student) GetBookList() []*Book {
	return s.books
}